package math;

import java.math.BigDecimal;

public class BigDecimalApp {

	public static void main(String[] args) {
		double price = 0.1f;
		double funds = 1.00;
		
		int itemsBought = 0;
		for(;funds >= price ; price += 0.1) {
			funds -= price;
			itemsBought++;
		}
		
		System.out.println(itemsBought);
		System.out.println(funds);
		
		// ---------------------
		m1();
	}
	
	private static void m1() {
		final BigDecimal TEN_CENTS = BigDecimal.valueOf(0.1);
		
		BigDecimal funds = BigDecimal.valueOf(1.0);
		int itemsBought = 0;
		for(BigDecimal price = TEN_CENTS ;funds.compareTo(price)>=0 ; price = price.add(TEN_CENTS)) {
			funds = funds.subtract(price);
			itemsBought++;
		}
		
		System.out.println(itemsBought);
		System.out.println(funds);
	}
}
